# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# Contributor: Michael Mason <ms13sp@gmail.com>
# Contributor: Bartłomiej Piotrowski <nospam@bpiotrowski.pl>
# Contributor: TBK <alpine@jjtc.eu>
pkgname=gawk
pkgver=5.3.1
pkgrel=0
pkgdesc="GNU awk pattern-matching language"
url="https://www.gnu.org/software/gawk/gawk.html"
arch="all"
license="GPL-3.0-or-later"
checkdepends="coreutils diffutils"
subpackages="$pkgname-doc"
source="https://ftp.gnu.org/gnu/gawk/gawk-$pkgver.tar.xz
	echild-strerror.patch
	"

case "$CARCH" in
# TODO: sigpipe1 test fails
# See: https://lists.gnu.org/archive/html/bug-gawk/2021-02/msg00005.html
s390x) options="!check" ;; # sigpipe1 test fails
esac

prepare() {
	default_prepare

	# TODO: https://lists.gnu.org/archive/html/bug-gawk/2021-02/msg00005.html
	sed -i test/Makefile.in -e "/clos1way6/d"
}

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-nls \
		--disable-pma
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
c6b4c50ce565e6355ca162955072471e37541c51855c0011e834243a7390db8811344b0c974335844770e408e1f63d72d0d81459a081c392e0245c726019eaff  gawk-5.3.1.tar.xz
5bbb175da2d93c9c1d422a4e5a2c2400486c0204929ac6771bf2c2effbee37b84ef9441821a47e1fdc4a337e3cb8ad92cb67d473822876ea790dd373822d4dbd  echild-strerror.patch
"
